package com.dq.domain.evaluation;

import com.dq.vo.baseVo.VO;
import com.dq.domain.base.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author liuhui
 * @date 2019/11/20 0020 15:05:03
 */
@Data
@Entity
@ApiModel("评价模板")
public class EvaluationTemplate extends BaseEntity  implements VO.ToVO {
    @ApiModelProperty("父级")
    @ManyToOne
    protected EvaluationTemplate parent;

    @ApiModelProperty("评论模板名称")
    @NotBlank(message = "模板名称不能为空")
    protected String name;
    @ApiModelProperty("页面展示排序")
    @NotNull(message = "排序不能为空")
    protected Long sort;

    public EvaluationTemplate() { }
    public EvaluationTemplate(@NotBlank String name, @NotNull Long sort, EvaluationTemplate parent) {
        this.name = name;
        this.sort = sort;
        this.parent = parent;
    }


    @Data
    @ApiModel(value = "评价模板关系实体视图")
    public static class Vo implements VO {

    }
    @Override
    public VO toVO(boolean isRecursion) {
        Vo vo = new Vo();
        return vo;
    }

    @Data
    @ApiModel("门店端评价详情实体视图")
    public static class OrgEvaluationDetailVo{
        @ApiModelProperty("id")
        protected Long id;
        @ApiModelProperty("评价项目名称")
        protected String name;
        @ApiModelProperty("评价子项目集合")
        protected List<EvaluationTemplateChild.Vo> evaTemplateChildList;
    }
    public OrgEvaluationDetailVo toOrgEvaluationDetailVo(List<EvaluationTemplateChild.Vo> evaTemplateChildList){
        EvaluationTemplate.OrgEvaluationDetailVo orgEvaluationDetailVo = new EvaluationTemplate.OrgEvaluationDetailVo();
        orgEvaluationDetailVo.id = this.getId();
        orgEvaluationDetailVo.name = fmt(this.getName());
        orgEvaluationDetailVo.evaTemplateChildList =evaTemplateChildList;
        return orgEvaluationDetailVo;
    }

    @Data
    @ApiModel("小程序展示反馈表")
    public static class EvaluationTemplateVo{
        @ApiModelProperty
        protected Long id;
        @ApiModelProperty("评论模板名称")
        protected String name;

        protected List<EvaluationTemplateChild.EvaluationTemplateChildList> children;
    }
    public EvaluationTemplateVo toEvaluationTemplateVo(){
        EvaluationTemplateVo vo = new EvaluationTemplateVo();
        vo.id = this.id;
        vo.name = this.name;
        return vo;
    }
}
